
import os
import pty
import sys
import time
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-w",type='int',dest='wait_time',default=0)
opts, args = parser.parse_args()

#with open(sys.stdin,errors='ignore') as f:
m,s = pty.openpty()
print(os.ttyname(s))
time.sleep(opts.wait_time)

for l in sys.stdin:
    os.write(m,bytes(l,errors='ignore',encoding='ascii'))
    
os.close(m)
os.close(s)
